In [2]:
import pandas as pd
import matplotlib.pyplot as plt
import descartes
import geopandas as gpd
from shapely.geometry import Point, Polygon
import plotly.express as px

%matplotlib inline
In [3]:
points = pd.read_csv("D:/KyotoProject/plot/testPoint.csv")
In [4]:
points_1809 = pd.read_csv("D:/KyotoProject/plot/export_plot.csv")
In [5]:
points.head()
Out[5]:
uid index aid uptime pos cd1 cd2 cd3 year month day hour minute second longitude latitude
0 ea82386f4623428f8a242b4e17f318ff 11571002 ARUKUMACHIKYOTO 41:50.0 (34.9766046,135.6965579) Android ja_JP 3.0.50 2018 9 1 0 41 49.963188 34.976605 135.696558
1 ea82386f4623428f8a242b4e17f318ff 11572775 ARUKUMACHIKYOTO 42:59.7 (34.9678067,135.6703647) Android ja_JP 3.0.50 2018 9 1 1 42 59.720997 34.967807 135.670365
2 ea82386f4623428f8a242b4e17f318ff 11577524 ARUKUMACHIKYOTO 45:05.3 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 4 45 5.261448 34.967860 135.670429
3 ea82386f4623428f8a242b4e17f318ff 11578406 ARUKUMACHIKYOTO 17:43.6 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 5 17 43.611878 34.967860 135.670429
4 ea82386f4623428f8a242b4e17f318ff 11580267 ARUKUMACHIKYOTO 18:25.9 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 6 18 25.923246 34.967860 135.670429
In [6]:
points_1809.head()
Out[6]:
uid index aid uptime pos cd1 cd2 cd3 year month day hour minute second longitude latitude
0 ea82386f4623428f8a242b4e17f318ff 11571002 ARUKUMACHIKYOTO 2018-09-01 00:41:49.963188 (34.9766046,135.6965579) Android ja_JP 3.0.50 2018 9 1 0 41 49.963188 34.976605 135.696558
1 ea82386f4623428f8a242b4e17f318ff 11572775 ARUKUMACHIKYOTO 2018-09-01 01:42:59.720997 (34.9678067,135.6703647) Android ja_JP 3.0.50 2018 9 1 1 42 59.720997 34.967807 135.670365
2 ea82386f4623428f8a242b4e17f318ff 11577524 ARUKUMACHIKYOTO 2018-09-01 04:45:05.261448 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 4 45 5.261448 34.967860 135.670429
3 ea82386f4623428f8a242b4e17f318ff 11578406 ARUKUMACHIKYOTO 2018-09-01 05:17:43.611878 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 5 17 43.611878 34.967860 135.670429
4 ea82386f4623428f8a242b4e17f318ff 11580267 ARUKUMACHIKYOTO 2018-09-01 06:18:25.923246 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 6 18 25.923246 34.967860 135.670429
In [8]:
#Insert unique index in the dataframe 
def insertIndex(df, index = 'uid'):
    """trasfer 'uid' in the data to integer unique ID, added into the 'idIndex' column.
   df = data frame file
   index = the columne name of the dataframe you want to use to generate the unique index, default value = 'uid'
    """
    nameList = list(df[index].unique())
    print("number of the unique index value: ",len(nameList))
    length = len(df)
    k = []
    for item in range(length):
        i = nameList.index(df['uid'][item])
        k.append(i)
    df['idIndex'] = k
    print(df.head())
    return df
In [9]:
plot_1809 = insertIndex(points_1809, index = 'uid')
number of the unique index value:  4358
                                uid     index              aid  \
0  ea82386f4623428f8a242b4e17f318ff  11571002  ARUKUMACHIKYOTO   
1  ea82386f4623428f8a242b4e17f318ff  11572775  ARUKUMACHIKYOTO   
2  ea82386f4623428f8a242b4e17f318ff  11577524  ARUKUMACHIKYOTO   
3  ea82386f4623428f8a242b4e17f318ff  11578406  ARUKUMACHIKYOTO   
4  ea82386f4623428f8a242b4e17f318ff  11580267  ARUKUMACHIKYOTO   

                       uptime                       pos      cd1    cd2  \
0  2018-09-01 00:41:49.963188  (34.9766046,135.6965579)  Android  ja_JP   
1  2018-09-01 01:42:59.720997  (34.9678067,135.6703647)  Android  ja_JP   
2  2018-09-01 04:45:05.261448  (34.9678602,135.6704294)  Android  ja_JP   
3  2018-09-01 05:17:43.611878  (34.9678602,135.6704294)  Android  ja_JP   
4  2018-09-01 06:18:25.923246  (34.9678602,135.6704294)  Android  ja_JP   

      cd3  year  month  day  hour  minute     second  longitude    latitude  \
0  3.0.50  2018      9    1     0      41  49.963188  34.976605  135.696558   
1  3.0.50  2018      9    1     1      42  59.720997  34.967807  135.670365   
2  3.0.50  2018      9    1     4      45   5.261448  34.967860  135.670429   
3  3.0.50  2018      9    1     5      17  43.611878  34.967860  135.670429   
4  3.0.50  2018      9    1     6      18  25.923246  34.967860  135.670429   

   idIndex  
0        0  
1        0  
2        0  
3        0  
4        0  
In [10]:
plot_1809.head()
Out[10]:
uid index aid uptime pos cd1 cd2 cd3 year month day hour minute second longitude latitude idIndex
0 ea82386f4623428f8a242b4e17f318ff 11571002 ARUKUMACHIKYOTO 2018-09-01 00:41:49.963188 (34.9766046,135.6965579) Android ja_JP 3.0.50 2018 9 1 0 41 49.963188 34.976605 135.696558 0
1 ea82386f4623428f8a242b4e17f318ff 11572775 ARUKUMACHIKYOTO 2018-09-01 01:42:59.720997 (34.9678067,135.6703647) Android ja_JP 3.0.50 2018 9 1 1 42 59.720997 34.967807 135.670365 0
2 ea82386f4623428f8a242b4e17f318ff 11577524 ARUKUMACHIKYOTO 2018-09-01 04:45:05.261448 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 4 45 5.261448 34.967860 135.670429 0
3 ea82386f4623428f8a242b4e17f318ff 11578406 ARUKUMACHIKYOTO 2018-09-01 05:17:43.611878 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 5 17 43.611878 34.967860 135.670429 0
4 ea82386f4623428f8a242b4e17f318ff 11580267 ARUKUMACHIKYOTO 2018-09-01 06:18:25.923246 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 6 18 25.923246 34.967860 135.670429 0
In [105]:
#points_test = points[50:200]
#points_test = points_1809[0:20000]
In [11]:
#select the data points with specific 'idIndex'
filterList = list(range(0,100)) # select the frist 50 idindex of points
points_test = plot_1809[plot_1809['idIndex'].isin(filterList)]
print(len(points_test),'points')
points_test.head()
68303 points
Out[11]:
uid index aid uptime pos cd1 cd2 cd3 year month day hour minute second longitude latitude idIndex
0 ea82386f4623428f8a242b4e17f318ff 11571002 ARUKUMACHIKYOTO 2018-09-01 00:41:49.963188 (34.9766046,135.6965579) Android ja_JP 3.0.50 2018 9 1 0 41 49.963188 34.976605 135.696558 0
1 ea82386f4623428f8a242b4e17f318ff 11572775 ARUKUMACHIKYOTO 2018-09-01 01:42:59.720997 (34.9678067,135.6703647) Android ja_JP 3.0.50 2018 9 1 1 42 59.720997 34.967807 135.670365 0
2 ea82386f4623428f8a242b4e17f318ff 11577524 ARUKUMACHIKYOTO 2018-09-01 04:45:05.261448 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 4 45 5.261448 34.967860 135.670429 0
3 ea82386f4623428f8a242b4e17f318ff 11578406 ARUKUMACHIKYOTO 2018-09-01 05:17:43.611878 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 5 17 43.611878 34.967860 135.670429 0
4 ea82386f4623428f8a242b4e17f318ff 11580267 ARUKUMACHIKYOTO 2018-09-01 06:18:25.923246 (34.9678602,135.6704294) Android ja_JP 3.0.50 2018 9 1 6 18 25.923246 34.967860 135.670429 0
In [12]:
token = "https://api.mapbox.com/tokens/v2/haomingyang?access_token=sk.eyJ1IjoiaGFvbWluZ3lhbmciLCJhIjoiY2szOGd6OWEwMDhxaTNjcnRxYXl2eXJ1ayJ9.IekZ9PZJeaVKaZqtHGTooQ" # you will need your own token
fig = px.scatter_mapbox(points_test, lat="longitude", lon="latitude", hover_name="idIndex", hover_data=["month", "day", "hour", "minute"],
                        color_discrete_sequence=["fuchsia"], zoom=6, height=800,  color="idIndex", size = "month", size_max = 6, color_continuous_scale=px.colors.cyclical.IceFire)
fig.update_layout(mapbox_style="open-street-map")
#fig.update_layout(mapbox_style="dark", mapbox_accesstoken=token)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
In [14]:
token = "pk.eyJ1IjoiaGFvbWluZ3lhbmciLCJhIjoiY2szOGd2amIyMDllZzNjcWpqNnF6MjU0YyJ9.2dKHbwUYHrGe_V2bv0RXaQ" # you will need your own token
fig = px.scatter_mapbox(points_test, lat="longitude", lon="latitude", hover_name="idIndex", hover_data=["month", "day", "hour", "minute"],
                        color_discrete_sequence=["fuchsia"], zoom=6, height=1000,  color="idIndex", size = "hour", size_max = 5, color_continuous_scale=px.colors.cyclical.IceFire)
#fig.update_layout(mapbox_style="open-street-map")
fig.update_layout(mapbox_style="dark", mapbox_accesstoken=token)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
In [16]:
import sys
!conda install --yes --prefix {sys.prefix} nbconvert
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: D:\Anaconda\anaconda

  added / updated specs:
    - nbconvert


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    nbconvert-5.6.1            |           py37_0         512 KB
    ------------------------------------------------------------
                                           Total:         512 KB

The following packages will be UPDATED:

  nbconvert          pkgs/main/noarch::nbconvert-5.5.0-py_0 --> pkgs/main/win-64::nbconvert-5.6.1-py37_0



Downloading and Extracting Packages

nbconvert-5.6.1      | 512 KB    |            |   0% 
nbconvert-5.6.1      | 512 KB    | ########## | 100% 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
In [18]:
jupyter nbconvert --to html NOTEBOOK-NAME.ipynb
  File "<ipython-input-18-a908f243614a>", line 1
    jupyter nbconvert --to html NOTEBOOK-NAME.ipynb
                    ^
SyntaxError: invalid syntax